﻿<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, admin-scalable=no" />
<title>用户</title>
<link rel="icon" href="favicon.ico" type="image/ico">


<meta name="author" content="yinqi">
  <link href="css/bootstrap.min.css" rel="stylesheet" th:href="@{/css/bootstrap.min.css}">
  <link href="css/materialdesignicons.min.css" rel="stylesheet" th:href="@{/css/materialdesignicons.min.css}">
  <link href="css/style.css" rel="stylesheet" th:href="@{/css/style.css}">
</head>
  
<body data-logobg="color_8" data-sidebarbg="color_8">
<div class="layout-web">
  <div class="layout-container">
    <!--左侧导航-->
    <div th:replace="common/commn :: aside"></div>
    <!--End 左侧导航-->

    <!--头部信息-->
    <div th:replace="common/commn :: #header"></div>
    <!--End 头部信息-->
    
    <!--页面主要内容-->
    <main class="layout-content">
      
      <div class="container-fluid">
        
        <div class="row">
          <div class="col-lg-12">
            <div class="card">
              <div class="card-toolbar clearfix">
                <form class="pull-right search-bar" method="get" action="#!" role="form">
                  <div class="input-group">
                    <div class="input-group-btn">
                      <input type="hidden" name="search_field" id="search-field" value="title">
                      <button class="btn btn-default dropdown-toggle" id="search-btn" data-toggle="dropdown" type="button" aria-haspopup="true" aria-expanded="false">
                      标题 <span class="caret"></span>
                      </button>
                      <ul class="dropdown-menu">
                        <li> <a tabindex="-1" href="javascript:void(0)" data-field="title">标题</a> </li>
                        <li> <a tabindex="-1" href="javascript:void(0)" data-field="cat_name">栏目</a> </li>
                      </ul>
                    </div>
                    <input type="text" class="form-control" value="" name="keyword" placeholder="请输入名称">
                  </div>
                </form>
                <div class="toolbar-btn-action">
                  <a class="btn btn-primary m-r-5" href="#!" th:href="@{/userAdd.html}"><i class="mdi mdi-plus"></i> 新增</a>
                </div>
              </div>
              <div class="card-body">
                
                <div class="table-responsive">
                  <table class="table table-bordered">
                    <thead>
                      <tr>
                        <th>
                          <label class="checkbox checkbox-primary">
                            <input type="checkbox" id="check-all"><span></span>
                          </label>
                        </th>
                        <th>uid</th>
                        <th>bid</th>
                        <th>账号</th>
                        <th>密码</th>
                        <th>借阅书籍</th>
                        <th>借书时间</th>
                      </tr>
                    </thead>
                    <tbody>
                      <tr th:each="user:${users.list}">
                        <td>
                          <label class="checkbox checkbox-primary">
                            <input type="checkbox" name="ids[]" value="1"><span></span>
                          </label>
                        </td>
                        <td th:text="${user.uid}">uid</td>
                        <td th:text="${user.bid}">bid</td>
                        <td th:text="${user.username}">账号</td>
                        <td th:text="${user.password}">密码</td>
                        <td th:text="${user.book}">借阅书籍</td>
                        <td th:text="${user.time}">借阅书籍</td>
                        <td>
                          <div class="btn-group">
                            <a class="btn btn-xs btn-default" href="#!" th:href="@{/user/}+${/user.uid}" title="编辑" data-toggle="tooltip"><i class="mdi mdi-pencil"></i></a>
                            <a class="btn btn-xs btn-default delete" th:attr="active_uri=@{/user/}+${user.uid}" href="#!"  title="删除" data-toggle="tooltip"><i class="mdi mdi-window-close"></i></a>
                          </div>
                        </td>
                      </tr>
                    </tbody>
                  </table>
                </div>
                <ul class="pagination">
                  <li><a th:href="@{/users(page=1,size=5)}">首页</a></li>
                  <li><a th:href="@{/users(page=${users.pageNum-1},size=5)}">上一页</a></li>
                  <li th:each="pageNums :${#numbers.sequence(users.firstPage,users.lastPage)}">
                    <a th:href="@{/users(page=${pageNums},size=5)}" th:text="${pageNums}">1</a>
                  </li>
                  <li><a th:href="@{/users(page=${users.pageNum+1},size=5)}">下一页</a></li>
                  <li><a th:href="@{/users(page=${users.pages},size=5)}">尾页</a></li>
                </ul>
              <form id="deleteForm" method="post">
                <input type="hidden" name="_method" value="delete">
              </form>
              </div>
            </div>
          </div>
          
        </div>
        
      </div>
      
    </main>
    <!--End 页面主要内容-->
  </div>
</div>

<script type="text/javascript" th:src="@{/js/jquery.min.js}" src="js/jquery.min.js"></script>
<script type="text/javascript" th:src="@{/js/bootstrap.min.js}" src="js/bootstrap.min.js"></script>
<script type="text/javascript" th:src="@{/js/perfect-scrollbar.min.js}" src="js/perfect-scrollbar.min.js"></script>
<script type="text/javascript" th:src="@{/js/main.js}" src="js/main.js"></script>
<script type="text/javascript">
$(function(){
    $('.search-bar .dropdown-menu a').click(function() {
        var field = $(this).data('field') || '';
        $('#search-field').val(field);
        $('#search-btn').html($(this).text() + ' <span class="caret"></span>');
    });
});
</script>
<script>
  $(".delete").click(function () {
    $("#deleteForm").attr("action",$(this).attr("active_uri")).submit();
  })
</script>
</body>
</html>